//
//  GuestSecViewController.m
//  MyProject
//
//  Created by dllo on 15/11/10.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//


//      猜猜看二级页面
#import "GuestSecViewController.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface GuestSecViewController ()<UIWebViewDelegate>
{
    UIWebView *webView;
     UIActivityIndicatorView *activityIndicator;
}
@end

@implementation GuestSecViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

   
    
    
    UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    [self.view addSubview:image];
    [image release];
    image.image =[UIImage imageNamed:@"beijing.png"];
    
    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:self.dic[@"url"]]];
  
    NSLog(@"%@", self.dic[@"url"]);
    [self.view addSubview: webView];
    [webView loadRequest:request];
   
    webView.delegate=self;
    UIScrollView *scollview=(UIScrollView *)[[webView subviews]objectAtIndex:0];
    scollview.bounces=NO;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//      网页开始加载的时候调用
- (void )webViewDidStartLoad:(UIWebView  *)webView{
    
    //创建UIActivityIndicatorView背底半透明View
    UIView *view = [[UIView alloc] initWithFrame:self.view.bounds];
    [view setTag:108];
    [view setBackgroundColor:[UIColor blackColor]];
    [view setAlpha:0.5];
    [self.view addSubview:view];
    
    
    
    
    
    //      指定进度轮的大小
    activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
    
    //      指定进度轮中心点
    [activityIndicator setCenter:view.center];
    
    //      设置进度轮显示类型, 系统提供了三种类型
    [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
    
    
    //      设置背景色
    activityIndicator.backgroundColor = [UIColor grayColor];
    
    //      设置背景透明
    activityIndicator.alpha = 0.5;
    
    //      设置背景为圆角矩形
    activityIndicator.layer.cornerRadius = 6;
    activityIndicator.layer.masksToBounds = YES;
    
    
    //      将初始化好的indicator add到view中 ,可以将它附着在任何视图上，比如表格单元、或者视图：
    [view addSubview:activityIndicator];
    [activityIndicator startAnimating];
}


//      网页加载完成的时候调用
- (void )webViewDidFinishLoad:(UIWebView  *)webView{
    
    [activityIndicator stopAnimating];
    UIView *view = (UIView*)[self.view viewWithTag:108];
    [view removeFromSuperview];
    NSLog(@"webViewDidFinishLoad");
    
}


//      网页加载错误的时候调用
- (void)webView:(UIWebView *)webView  didFailLoadWithError:(NSError *)error{
    [activityIndicator stopAnimating];
    UIView *view = (UIView*)[self.view viewWithTag:108];
    [view removeFromSuperview];
    NSLog(@"sha");
}


@end
